<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.0</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="shortcut icon" href="__STATIC__/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="__STATIC__/css/font.css">
    <link rel="stylesheet" href="__STATIC__/css/xadmin.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script type="text/javascript" src="__STATIC__/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="__STATIC__/js/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body>
<div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="">首页</a>
        <a href="">分销管理</a>
        <a>
          <cite>服务员提成</cite></a>
      </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">&#xe666;</i></a>
</div>
<div class="x-body">
    <div class="layui-row" style="text-align: center">
        <form class="layui-form layui-col-md12 x-so">
            <input class="layui-input" placeholder="开始日" name="start" id="start" autocomplete="off" lay-verify="required">
            <input class="layui-input" placeholder="截止日" name="end" id="end" autocomplete="off"  lay-verify="required">
            <div class="layui-input-inline">
                <select name="shop_id" lay-filter="shop_id" lay-verify="required">
                    <option value="0">请选择店铺</option>
                    {volist name="data" id="vo"}
                    <option value="{$vo.id}">{$vo.shop_name}</option>
                    {/volist}
                </select>
            </div>
            <div class="layui-input-inline" >
                <select name="user_id">
                </select>
            </div>
            <button class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
        </form>
    </div>
    <table class="layui-table" id="demo"></table>

</div>
<script>
    layui.use(['form','laydate','table'], function(){
        var form = layui.form
            ,laydate = layui.laydate
            ,table = layui.table;
            laydate.render({
                elem: '#start' //指定元素
            });
            laydate.render({
                elem: '#end' //指定元素
            });

        form.on('select(shop_id)',function (data) {
            if (data.value != 0){
                $.post('{:url("distribution/waiters")}',{shop_id:data.value},function (res) {
                    // console.log(res);
                    $('select[name="user_id"]').empty();
                    $.each(res,function (index) {
                        $('select[name="user_id"]').append('<option value="'+ $(this)[0].id +'">'+ $(this)[0].true_name +'</option>')
                    });
                    form.render('select');
                });
            }else {
                $('select[name="user_id"]').empty();
                form.render('select');
            }
        });
        form.on('submit(sreach)',function (data) {
            table.render({
                elem: '#demo'
                ,url: '{:url("distribution/waiterData")}' //数据接口
                ,where:{
                    user_id:data.field.user_id,
                    start:data.field.start,
                    end:data.field.end,
                }
                ,page: true //开启分页
                ,cols: [[ //表头
                    {field: 'id', title: 'ID' ,fixed: 'left'}
                    ,{field: 'user_id', title: '服务员'}
                    ,{field: 'order_no', title: '订单号'}
                    ,{field: 'total', title: '总消费'}
                    ,{field: 'number', title: '人数'}
                    ,{field: 'money', title: '提成金额'}
                    ,{field: 'status', title: '提成方式'}
                    ,{field: 'create_time', title: '分销时间'}
                ]]
            });
            return false;
        });
    });
</script>
</body>

</html>